import type { IContentConfig } from '@/components/CURD/types'

const contentConfig: IContentConfig = {
    pageName: 'sys:user',
    table: {
        showOverflowTooltip: true
    },
    toolbar: [],
    indexAction: function (params) {
        // 模拟发起网络请求获取列表数据
        // console.log("indexAction:", params);
        return Promise.resolve({
            total: 2,
            list: [
                {
                    id: 1,
                    username: 'tom',
                    avatar: 'https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif',
                    percent: 99,
                    price: 10,
                    url: 'https://www.baidu.com',
                    icon: 'el-icon-setting',
                    gender: 1,
                    status: 1,
                    status2: 1,
                    sort: 99,
                    createdAt: 1715647982437
                },
                {
                    id: 2,
                    username: 'jerry',
                    avatar: 'https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif',
                    percent: 88,
                    price: 999,
                    url: 'https://www.google.com',
                    icon: 'el-icon-user',
                    gender: 0,
                    status: 0,
                    status2: 0,
                    sort: 0,
                    createdAt: 1715648977426
                }
            ]
        })
    },
    modifyAction(data) {
        // 模拟发起网络请求修改字段
        // console.log("modifyAction:", data);
        ElMessage.success(JSON.stringify(data))
        return Promise.resolve(null)
    },
    cols: [
        { type: 'index', width: 50, align: 'center' },
        { label: 'ID', align: 'center', prop: 'id', show: false },
        { label: '文本', align: 'center', prop: 'username' },
        { label: '图片', align: 'center', prop: 'avatar', templet: 'image' },
        {
            label: '百分比',
            align: 'center',
            prop: 'percent',
            templet: 'percent'
        },
        {
            label: '货币符',
            align: 'center',
            prop: 'price',
            templet: 'price',
            priceFormat: '$'
        },
        {
            label: '链接',
            align: 'center',
            prop: 'url',
            width: 180,
            templet: 'url'
        },
        { label: '图标', align: 'center', prop: 'icon', templet: 'icon' },
        {
            label: '列表值',
            align: 'center',
            prop: 'gender',
            templet: 'list',
            selectList: { 0: '女', 1: '男' }
        },
        {
            label: '自定义',
            align: 'center',
            prop: 'status',
            templet: 'custom',
            slotName: 'status'
        },
        {
            label: 'Switch',
            align: 'center',
            prop: 'status2',
            templet: 'switch',
            activeValue: 1,
            inactiveValue: 0,
            activeText: '启用',
            inactiveText: '禁用'
        },
        {
            label: '输入框',
            align: 'center',
            prop: 'sort',
            templet: 'input',
            inputType: 'number'
        },
        {
            label: '日期格式化',
            align: 'center',
            prop: 'createdAt',
            minWidth: 120,
            templet: 'date',
            dateFormat: 'YYYY/MM/DD HH:mm:ss'
        },
        {
            label: '操作栏',
            align: 'center',
            fixed: 'right',
            width: 220,
            templet: 'tool',
            operat: [
                {
                    name: 'reset_pwd',
                    auth: 'password:reset',
                    icon: 'refresh-left',
                    text: '重置密码',
                    type: 'primary',
                    render(row) {
                        return row.id === 1
                    }
                }
            ]
        }
    ]
}

export default contentConfig
